/* 
 * File:   ClusteringKMeans.h
 * Author: rolando
 *
 * Created on 15 de octubre de 2013, 13:08
 */

#ifndef CLUSTERINGKMEANS_H
#define	CLUSTERINGKMEANS_H

#include <vector>
#include <cstdlib>
#include <math.h>
#include <string.h>
#include <iostream>
#include <string.h>

#include "Jaccard.h"
#include "Directory.h"


using namespace std;

class ClusteringKMeans {
    
    //int **rawData;
    int numClusters;
    int numDocs;
    int numAttributes;
    int maxCount;
    vector<string> files;
    HashSet** centroides;
    HashSet** docs;
    int* changedCluster;
    int* indices;
    int maxCache;
public:
    ClusteringKMeans();
    ClusteringKMeans(vector<string>, int, int, int, int);
    virtual ~ClusteringKMeans();
    int **Cluster(bool);
    void SaveFiles(int**,const char*,const char*,const char*,const char*);
private:

    int **InitClustering();
    double **Allocate();
    //void UpdateMeans(int *, double **);
    //void UpdateCentroids(int *, double **, double **);
    //double *ComputeCentroid(int *, int, double **);
    double Distance(int *, double*);
    //bool Assign(int *, double **);
    int MinIndex(double *);
    void CalculateCentroid(int *);
    void OptimiceCentroid(int *);
    HashSet* GetRowData(int);
    HashSet* GetHashSet(int,bool*);
    bool AssignElem(int *);
    bool AssignElemVariosCluster(int **);
    bool IsCentroid(int );
    int Busco_Barra_Final(const char*);

};

#endif	/* CLUSTERINGKMEANS_H */

